package com.jiawa.langchain4j.controller;

import com.jiawa.langchain4j.aiservice.ConsultantService;
import dev.langchain4j.model.openai.OpenAiChatModel;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class chatController {

    /*@Resource
    private OpenAiChatModel openAiChatModel;

    @RequestMapping("/chat")
    public String chat(String message) {
        String chat = openAiChatModel.chat(message);
        return chat;
    }*/

    @Autowired(required = true)
    private ConsultantService consultantService;

    /*@RequestMapping("/chat")
    public String chat(String message) {
        String chat = consultantService.chat(message);
        return chat;
    }*/
    @RequestMapping(value = "/chat",produces = "text/html;charset=utf-8")
    public Flux<String> chat(String memoryId,String message) {
        Flux<String> chat = consultantService.chat(memoryId,message);
        return chat;
    }
}
